package com.sias.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 吴文杰
 * @version 1.0
 * @createTime 2023-05-03 14:49:38
 */
public class HomeWork03 {
  public static void main(String[] args) {
    String content = "http://www.sohu.com:8080/abc/index.html";
    String regStr = "^(\\w+)://([\\w.]+):(\\d+)[\\w-/]+/([\\w.]+)$";
    Pattern pattern = Pattern.compile(regStr);
    Matcher matcher = pattern.matcher(content);
    while (matcher.find()){
      System.out.println("协议："+matcher.group(1));
      System.out.println("域名："+matcher.group(2));
      System.out.println("端口："+matcher.group(3));
      System.out.println("文件名："+matcher.group(4));
    }
  }
}
